<template>
    <div>
<table>
    <tbody>
        <tr>
            <td>姓名</td>
            <td>
                <input type="text" name="" v-model="date.name" id="">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="text" name="" v-model="date.pwd" id="">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" value="登录" @click="login">
            </td>
            
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const router=useRouter()
const login=()=>{
    axios.get('https://localhost:7094/api/Emp',{params:date.value}).then(res=>{
if(res.data.id==-1){
    alert('用户名不存在')
    return
}else if(res.data.id==-2){
    alert('密码错误')
    return
}else{
    alert('成功')
router.push({path:"/add"})

}
    })
}
// const login=()=>{
//     axios.get('').then(res=>{
        
//     })
// }
const date=ref({
    name:"",
    pwd:""
})
</script>

<style scoped>

</style>